<template>
  <view>
    <el-table @row-click="clickRow" ref="refTable" :data="dataList" @selection-change="handleSelectionChange" height="400px">
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column label="ID" prop="id" :show-overflow-tooltip="true" />
      <el-table-column label="训练集名称" prop="fileName" :show-overflow-tooltip="true" />
      <el-table-column label="训练集类型" prop="extName" :show-overflow-tooltip="true" />
      <el-table-column label="唯一key" prop="md5" :show-overflow-tooltip="true" />
      <el-table-column label="存储位置" prop="storageMode" :show-overflow-tooltip="true" />
      <!-- <el-table-column label="路径" prop="path" :show-overflow-tooltip="true" /> -->
    </el-table>
  </view>
</template>

<script setup>
import request from "@/utils/request";
import { queryList, deleteOne, queryOne } from "../../../module/disk/api/data";
import { onMounted, defineProps } from "vue";
const dataList = ref([]);
const emit = defineEmits(["confirm", "Ids","data"]);
const { proxy } = getCurrentInstance();
const props = defineProps({
  Ids: {
    type: Array,
  },
  data:{
    type:Object
  }
});
// 多选框选中数据
function handleSelectionChange(selection) {
  //proxy.$refs["refTable"].clearSelection();
  var list = selection.map((item) => item.id);
  console.log(list);
  emit("update:Ids", list);
  if(list.length == 1){
    let id = list[0];
    let obj = null;

    dataList.value.forEach(ele=>{
        if(ele.id == id){
            obj = ele;
        }
    })
    emit("update:data",obj)
  }

}
function initData() {
  let queryParams = {
    pageSize:20,
    pageNum:1
  }
  queryList(queryParams).then(res=>{
    console.log(res)
    dataList.value = res.content;
  })
}
onMounted(() => {
  initData();
});
</script>
